<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function isIntersection(range1Start, range1End, range2Start, range2End) {
        const start1 = new Date(`2000-01-01T${range1Start}`);
        const end1 = new Date(`2000-01-01T${range1End}`);
        const start2 = new Date(`2000-01-01T${range2Start}`);
        const end2 = new Date(`2000-01-01T${range2End}`);

        return start1 <= end2 && end1 >= start2;
    }

    // 示例
    const overlapExists = isIntersection("08:30", "09:30", "09:31", "10:30");

    if (overlapExists) {
        console.log("时间段存在交集");
    } else {
        console.log("时间段不存在交集");
    }


    function addMinutesToTime(timeString, minutesToAdd) {
        // 将时间字符串转换为日期对象
        const baseTime = new Date(`2000-01-01T${timeString}`);

        // 添加指定分钟数
        baseTime.setMinutes(baseTime.getMinutes() + minutesToAdd);

        // 格式化为 HH:mm 形式
        const formattedTime = `${(baseTime.getHours() < 10 ? '0' : '')}${baseTime.getHours()}:${(baseTime.getMinutes() < 10 ? '0' : '')}${baseTime.getMinutes()}`;

        return formattedTime;
    }

    // 示例
    const originalTime = "08:59";
    const newTime = addMinutesToTime(originalTime, 1); // 在原时间上增加15分钟

    console.log(`原时间：${originalTime}`);
    console.log(`新时间：${newTime}`);


</script>
</body>
</html>
